﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class _default : System.Web.UI.Page
    {
        private static readonly string DefaultUserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36";
        protected void Page_Load(object sender, EventArgs e)
        {
            ServicePointManager.ServerCertificateValidationCallback =
                new System.Net.Security.RemoteCertificateValidationCallback((a, b, c, d) =>
                {
                    return true;
                });


            var url = "http://vjsadmin.5173.com/";
            url = "https://passport.5173.com";
            url = "https://play.google.com/store";
            var uri = new Uri(url);
            HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(uri);
            req.UserAgent = DefaultUserAgent;
            req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
            req.KeepAlive = true;
            req.ProtocolVersion = new Version(1, 1);
            req.CookieContainer = new CookieContainer();
            req.Credentials = CredentialCache.DefaultNetworkCredentials;
            var hh = req.CookieContainer.GetCookies(uri);
            Console.WriteLine(hh.Count);
            var response = (HttpWebResponse)req.GetResponse();

            var cookies = response.Headers.Get("Set-Cookie");
            Console.WriteLine(cookies);

            StreamReader strReader = new StreamReader(response.GetResponseStream());
            string responseStr = strReader.ReadToEnd();
            strReader.Close();
            Console.WriteLine(responseStr);
        }
    }
}